home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-06 | 3.2 KB | 136 lines | [TEXT/MPS ] |
- // Modeller_errors.c
- //
- // Error handling routines for the modeller App. Since this application was
- // designed primarily for demonstrating QuickDraw 3D, we'll just silently fail,
- // and write escher messages to a file.
- //
- // The debugging log is primarily there to help debug, so get the users to send the
- // logfile in when they report problems.
- //
- // Author: Nick Thompson, 11/24/94
- //
- // Modification History:
- //
- // 11/26/94 nick Initial Cut - based on code from spin
- //
- // Copyright © 1992-94 Apple Computer, Inc., All Rights Reserved
- //
-
- #include <stdlib.h>
- #include <stdarg.h>
- #include <stdio.h>
-
- #include "QD3D.h"
- #ifndef ESCHER_VER_15
- #define ESCHER_VER_15 1 /* THIS IS A BUG in Escher_Error.h! */
- #endif
- #include "QD3DErrors.h"
-
- #include "Error_Lib.h"
- #include "Error_MesgLib.h"
-
- #include "Modeller_errors.h"
-
- static void MyErrorHandler( TQ3Error first, TQ3Error last, long reference);
- static void MyNoticeHandler( TQ3Notice first, TQ3Notice last, long reference);
- static void MyWarningHandler( TQ3Warning first, TQ3Warning last, long reference);
-
- static FILE *pErrorFile = NULL;
-
-
- //-----------------------------------------------------------------------------
- //
- void MyError(
- char *fxnName,
- char *string,
- ...)
- {
- char message[512];
- va_list argList;
-
- va_start(argList, string);
- vsprintf(message, string, argList);
- va_end(argList);
-
- // we should allways have a console window availavle
- sprintf("Error:%s:%s\n", fxnName, message);
-
- if (pErrorFile == NULL)
- pErrorFile = fopen("error.output","w+");
-
- if (pErrorFile != NULL)
- fputs(message, pErrorFile);
-
- }
-
- //-----------------------------------------------------------------------------
- //
- void MyErrorInit( void)
- {
- Q3Error_Register( MyErrorHandler, NULL );
- Q3Warning_Register( MyWarningHandler, NULL );
- Q3Notice_Register( MyNoticeHandler, NULL );
- }
-
- //-----------------------------------------------------------------------------
- //
- void MyErrorExit( void)
- {
- if (pErrorFile != NULL)
- fclose(pErrorFile);
- }
-
- //-----------------------------------------------------------------------------
- // MyErrorHandler - handle warnings from QuickDraw 3d
- static void MyErrorHandler( TQ3Error error, TQ3Error error2 , long reference)
- {
- char buf[512];
-
- sprintf(buf, "ERROR %d - %s\n",
- error, getErrorString(error));
-
-
- if (pErrorFile == NULL)
- pErrorFile = fopen("error.output","w+");
-
- if (pErrorFile != NULL)
- fputs(buf, pErrorFile);
- }
-
- //-----------------------------------------------------------------------------
- // MyWarningHandler - handle warnings from QuickDraw 3d
-
- static void MyWarningHandler( TQ3Warning warning, TQ3Warning warning2 , long reference)
- {
- char buf[512];
-
- sprintf(buf, "WARNING %d - %s\n",
- warning, getWarningString(warning));
-
-
- if (pErrorFile == NULL)
- pErrorFile = fopen("error.output","w+");
-
- if (pErrorFile != NULL)
- fputs(buf, pErrorFile);
- }
-
- //-----------------------------------------------------------------------------
- // MyNoticeHandler - handle notices from QuickDraw 3d
-
- static void MyNoticeHandler( TQ3Notice notice, TQ3Notice notice2 , long reference)
- {
- char buf[512];
-
- sprintf(buf, "NOTICE %d\n",
- notice);
-
-
- if (pErrorFile == NULL)
- pErrorFile = fopen("error.output","w+");
-
- if (pErrorFile != NULL)
- fputs(buf, pErrorFile);
- }
-
-